
class Book:

    def __init__(self, name, author, comment, state = 0):
        self.name = name
        self.author = author
        self.comment = comment
        self.state = state
    def __str__(self):
        if self.state == 0:
            status = 'not borrow'
        else:
            status = 'borrowed'
        return 'name: <<%s>> author: %s comment is: %s status is: %s' %(self.name, self.author, self.comment, status)


book = Book('pua','liuxing','meet girl')
print(book.author)
print(book)

class BookManager:
    books = []

    def __init__(self):
        book1 = Book('pua 1','liuxing 1','meet girl 1')
        book2 = Book('pua 2', 'liuxing 2', 'meet girl 2')
        book3 = Book('pua 3', 'liuxing 3', 'meet girl 3')
        self.books.append(book1)
        self.books.append(book2)
        self.books.append(book3)

    def check_book(self, name):
        for book in self.books:
            if book.name == name:
                return book
        else:
            return None

    def menu(self):
        print('weclome to libary')

        print('1.fetch all books\n2.add book\n3.borrow book\n4.back book\n5.logout out systerm')

        while True:
            choice = int(input('please enter you select menu:'))
            if choice == 1:
                self.show_all_book()
            elif choice == 2:
                self.add_book()
            elif choice == 3:
                self.lend_book()
            elif choice == 4:
                self.return_book()
            elif choice == 5:
                print('thank you for use the systerm')
                break


    def show_all_book(self):
        for book in self.books:
            print(book)

    def add_book(self):

        new_name = raw_input('please enter the book name:')
        new_author = raw_input('please enter the book author:')
        new_comment = raw_input('please enter the book comment')

        new_book = Book(new_name, new_author, new_comment)
        self.books.append(new_book)
        print('add book success')

    def lend_book(self):
        name = raw_input('please enter the borrow book name:')
        res = self.check_book(name)
        for book in self.books:
            if book.name == name:
                if book.state == 1:
                    print('you are late, the book is already borrowed')
                else:
                    print('brrow success')
                    book.state == 1
                    break
            else:
                continue
        else:
            print('systerm not have this book')

    def return_book(self):
        pass

manager = BookManager()
lenght = len(manager.books)
print(lenght)

# manager.menu()
manager.lend_book()